﻿#include "currentparamwidget.h"

QCurrentParamWidget::QCurrentParamWidget(QWidget *parent) : QWidget(parent)
{
    InitUI();
    connect(_pCurrentAdjWidget,&QCurrentAdjWidget::signal_startTest,this,[=](int i32Axis,int workmode,int data,int data1)
    {
        emit signal_startTest(i32Axis,workmode,data,data1);
    });

    connect(_pCurrentAdjWidget,&QCurrentAdjWidget::signal_framedata,_pCurrentDesignWidget,&QCurrentDesignWidget::onRcvFrameData);
//    connect(_pCurrentTestWidget,&QCurrentTestWidget::signal_setpid,this,[=](int i32AxisNo,int nType,float lfkp,float lfki,float lfkd)
//    {
//        emit signal_setpid(i32AxisNo,nType,lfkp,lfki,lfkd);
//    });

}

/**
* @brief
*
**/
void QCurrentParamWidget::InitUI()
{
    _pTabWidget = new QTabWidget(this);
    _pCurrentAdjWidget = new QCurrentAdjWidget(this);
    _pCurrentDesignWidget = new QCurrentDesignWidget(this);
    _pCurrentTestWidget = new QCurrentTestWidget(this);

    _pTabWidget->addTab(_pCurrentAdjWidget,"电流参数整定");
    _pTabWidget->addTab(_pCurrentDesignWidget,"电流参数设计");
    _pTabWidget->addTab(_pCurrentTestWidget,"电流响应测试");

    _pTabWidget->setTabPosition(QTabWidget::South);


    QGridLayout* playout = new QGridLayout(this);
    playout->addWidget(_pTabWidget,0,0,1,1);

}
/**
* @brief
*
**/
void QCurrentParamWidget::rcvFrameData(st_rcvdata rcvdata)
{
    _rcvFramedata = rcvdata;

    if(_rcvFramedata.loopcmd == 0xBB)
    {
        _pCurrentAdjWidget->rcvFrameData(rcvdata.loopcmd_data.loopdata_BB);
    }
    if(_rcvFramedata.loopcmd == 0x11)
    {
        _pCurrentTestWidget->rcvFrameData(rcvdata.loopcmd_data.loopdata_11);
    }
}
